//package com.example.springbootlearn.security.config;
//
//import cn.hutool.json.JSONUtil;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.web.authentication.AuthenticationFailureHandler;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.HashMap;
//import java.util.Map;
//
//public class MyAuthenticationFailureHandler implements AuthenticationFailureHandler {
//
//    @Override
//    public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
//        response.setContentType("application/json;charset=utf-8");
//        Map<String, Object> resp = new HashMap<>();
//        resp.put("status", 500);
//        resp.put("msg", "登录失败!" + exception.getMessage());
//        response.getWriter().write(JSONUtil.toJsonStr(resp));
//    }
//}
